packetbeat.interfaces:
  device: {{ bind_interface }}
  type: af_packet
  buffer_size_mb: 100
  with_vlans: yes

packetbeat.flows:
  enabled: true
  timeout: 30s
  period: 120s

packetbeat.protocols:
  - type: icmp
    enabled: true
{% if 'redis' in group_names %}
  - type: redis
    ports: [6379]
{% endif %}

{% if 'haproxy' in group_names %}
packetbeat.procs:
  monitored:
    - process: haproxy
      cmdline_grep: haproxy
{% endif %}

#================================ Outputs =====================================
output.elasticsearch:
{% if searchguard_enabled %}
  hosts: ["https://ingest.elastic.service.{{ consul_dc_name }}.consul:{{ elastic_http_port }}"]
  username: haibin
  password: {{ sg_users | selectattr('id', 'eq', 'haibin') | map(attribute='pass') | first }}
  ssl:
    verification_mode: none
{% else %}
  hosts: ["http://ingest.elastic.service.{{ consul_dc_name }}.consul:{{ elastic_http_port }}"]
{% endif %}

{% if inventory_hostname == groups['all'][0] %}
#============================== Dashboards =====================================
setup.dashboards:
  enabled: true
  retry:
    enabled: true
    interval: 60s
    maximum: 10

#================================ Kibana =====================================
setup.kibana:
  host: "kibana.service.{{ consul_dc_name }}.consul"
{% endif %}

#================================ Logging =====================================
logging.to_files: true
logging.level: error
logging.files:
  rotateeverybytes: 10485760 # = 10MB
  keepfiles: 7

fields_under_root: true
fields:
    beat_type: packetbeat

name: {{ inventory_hostname }}

tags: [
{%- for item in group_names -%}
  "{{ item }}"{%- if loop.nextitem is defined -%},{%- endif -%}
{%- endfor -%}
]

{% if '6.3.0' is version(elk_version, operator='lt', strict=True) %}
#============================== Xpack Monitoring ===============================
xpack.monitoring:
  enabled: true
{% endif %}
